<?php echo $this->Form->create(array('action' => 'search', 'type' => 'GET', 'onsubmit' => 'return false')); ?>

 <?php $name = isset($this->params['url']['name']) ? $this->params['url']['name'] : 'Search'; ?>
  		<table border="0" cellpadding="0" cellspacing="0">
      		<tr>
        		<td>
                <?php 
                      echo $this->Form->input('search', array('div' => false, 'label'=>false,'value'=>$name, "onblur" => "if (this.value=='') { this.value='Search'; }", "onfocus" => "if (this.value=='Search') { this.value=''; }", "class" => "top-search-inp"));
                ?>
            </td>
        		<td>
            <?php $option = array('tickets' => 'Ticket', 'customers' => 'Company', 'courses' => 'Course', 'opensesion' => 'Open Session', 'onsitesesion' => 'OnSite Session', 'trainers' => 'Trainer'); ?>
                <?php 
                      echo $this->Form->input('location', array('div' => false, 'label' => false, 'options' => $option, "class" => "chosen", 'empty' => '--Category--'));
                ?>
        		</td>
        		<td>
                <?php echo $this->Form->submit('../images/search.png', array('div' => false, 'class' => 'submit-search')); ?>
        		</td>
      		</tr>
  		</table>
<?php echo $this->Form->end(); ?>   

<script type="text/javascript">
jQuery(document).ready(function(){
     jQuery(".submit-search").click(function(){
         var search = jQuery('.top-search-inp').val();
         var location = jQuery('.styledselect').val();

         if(search == '' || search == 'Search'){
              alert('Please fill search.');
              return false;
         }
         if(location == ''){
              alert('Please select Category.');
              return false;
         }
         if(location == 'opensesion'){
              location = 'open_sesions';
         }
         if(location == 'onsitesesion'){
              location = 'onsite_sesions';
         }
         if(location == 'customers'){
              url = "<?php echo $this->Html->url('/') ?>"+"superadmin/"+location+'/search_over?search='+search;
         }else{
              url = "<?php echo $this->Html->url('/') ?>"+"superadmin/"+location+"/search?search="+search;
         }
         window.location = url;
     });
});

</script>

